import json

import execjs
import requests
def start(word):
    cookies = {
        '_ga': 'GA1.2.608012681.1726029820',
        'sajssdk_2015_cross_new_user': '1',
        'auth_token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjYwNjI3ODc1LCJleHAiOjE3MjY4OTQxNjAsImV4cF92MiI6MTcyNjg5NDE2MCwiZGV2aWNlIjoiIiwidXNlcm5hbWUiOiJXZWNoYXRfYjQ1OTdkMTFlOWUxOTM1ZiIsImlzX3N0YWZmIjowLCJzZXNzaW9uX2lkIjoiODJhZjM0NDA2ZmY4MTFlZjg1NzM0YWU3ZWZiYTkxYjkifQ.ybcjc9xwQDeTwpfSRv2jlCc3fMBQwLupYcpvQf17pbQ',
        'csrftoken': 'd9858d879d14adc8f1179e2264c29e43',
        'tfstk': 'fIZq3e9K4iIVRxj6fxoZU_BOP2mxrmfISlGsIR2ihjcDct3azRVcHV_OkG4zs73jinijSAygpr6tmsPys72_fnwm1cuawWPZWthssfP_Ir65AMwYHcng_6sCAr6fQ8FqncDMqODEK5SY2OwYHcpRcZqUl-Lw1Xj0ScViq0DnncDmofXyExhkmAxmIQXrwAmMoAYDZgDtdhD0scXzEbHiN8GiO3kEo95LDhy9B9lKt-c0h-Ekjm8YLb-WVuzrnXjZahxg4xyJYWL6YNG3JjgIt7jW0cyoQ7uQu6-4_R2LS4rwitN3ZPPiezCw7XzghyESPdY0Ullq-o0yB9w3HAVi7zCeAxobz2r4kOdunWG4-me6Lswr8zuKE4vwomaQdl33miRKN2Haa2aVTnPh4IRtEtDLXrRM7qD-UX6PUya4d472iOYeWF3YyYlCHtL9WqD-UX6PUFLtk0HrOtBA.',
        'sensorsdata2015jssdkcross': '%7B%22distinct_id%22%3A%22gvbpgt%22%2C%22first_id%22%3A%22191df64f0b1806-08eac191d1abc-4c657b58-1327104-191df64f0b2815%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_referrer_host%22%3A%22%22%7D%2C%22%24device_id%22%3A%22191df64f0b1806-08eac191d1abc-4c657b58-1327104-191df64f0b2815%22%7D',
    }

    headers = {
        'accept': '*/*',
        'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
        # 'cookie': '_ga=GA1.2.608012681.1726029820; sajssdk_2015_cross_new_user=1; auth_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjYwNjI3ODc1LCJleHAiOjE3MjY4OTQxNjAsImV4cF92MiI6MTcyNjg5NDE2MCwiZGV2aWNlIjoiIiwidXNlcm5hbWUiOiJXZWNoYXRfYjQ1OTdkMTFlOWUxOTM1ZiIsImlzX3N0YWZmIjowLCJzZXNzaW9uX2lkIjoiODJhZjM0NDA2ZmY4MTFlZjg1NzM0YWU3ZWZiYTkxYjkifQ.ybcjc9xwQDeTwpfSRv2jlCc3fMBQwLupYcpvQf17pbQ; csrftoken=d9858d879d14adc8f1179e2264c29e43; tfstk=fIZq3e9K4iIVRxj6fxoZU_BOP2mxrmfISlGsIR2ihjcDct3azRVcHV_OkG4zs73jinijSAygpr6tmsPys72_fnwm1cuawWPZWthssfP_Ir65AMwYHcng_6sCAr6fQ8FqncDMqODEK5SY2OwYHcpRcZqUl-Lw1Xj0ScViq0DnncDmofXyExhkmAxmIQXrwAmMoAYDZgDtdhD0scXzEbHiN8GiO3kEo95LDhy9B9lKt-c0h-Ekjm8YLb-WVuzrnXjZahxg4xyJYWL6YNG3JjgIt7jW0cyoQ7uQu6-4_R2LS4rwitN3ZPPiezCw7XzghyESPdY0Ullq-o0yB9w3HAVi7zCeAxobz2r4kOdunWG4-me6Lswr8zuKE4vwomaQdl33miRKN2Haa2aVTnPh4IRtEtDLXrRM7qD-UX6PUya4d472iOYeWF3YyYlCHtL9WqD-UX6PUFLtk0HrOtBA.; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22gvbpgt%22%2C%22first_id%22%3A%22191df64f0b1806-08eac191d1abc-4c657b58-1327104-191df64f0b2815%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_referrer_host%22%3A%22%22%7D%2C%22%24device_id%22%3A%22191df64f0b1806-08eac191d1abc-4c657b58-1327104-191df64f0b2815%22%7D',
        'origin': 'https://web.shanbay.com',
        'priority': 'u=1, i',
        'referer': 'https://web.shanbay.com/',
        'sec-ch-ua': '"Chromium";v="128", "Not;A=Brand";v="24", "Microsoft Edge";v="128"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"Windows"',
        'sec-fetch-dest': 'empty',
        'sec-fetch-mode': 'cors',
        'sec-fetch-site': 'same-site',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0',
    }

    params = {
        'word': word,
    }

    response = requests.get('https://apiv3.shanbay.com/wordsapp/words/vocab', params=params, cookies=cookies, headers=headers)
    t=response.json()['data']
    with open('./扇贝单词.js', 'r', encoding='utf-8') as js_file:
        js_code = js_file.read()
    js_compile = json.loads(execjs.compile(js_code).call('d',t))['id']

    params = {
        'vocab_ids': js_compile,
    }

    response = requests.get('https://apiv3.shanbay.com/wordsapp/words/vocab_senses', params=params, cookies=cookies, headers=headers).json().get('data')

    with open('./扇贝单词.js', 'r', encoding='utf-8') as js_file:
        js_code = js_file.read()
    js_compile = json.loads(execjs.compile(js_code).call('d',response))['objects']
    print(json.dumps(js_compile, ensure_ascii=False, indent=4))

start('fuck')